package net.starwifi.duobao.service.impl;


import net.starwifi.duobao.entity.Refunds;
import net.starwifi.duobao.repository.RefundsRepository;
import net.starwifi.duobao.service.BaseServiceImpl;
import net.starwifi.duobao.service.RefundsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

@Service
public class RefundsServiceImpl extends BaseServiceImpl<Refunds,Long> implements RefundsService {

    @Autowired
    RefundsRepository repository;

    @Override
    public Refunds findBySn(String sn) {
        return repository.findBySn(sn);
    }

    @Override
    public Refunds findByOrderSn(String orderSn) {
        return repository.findByOrderSn(orderSn);
    }

    /** 退款成功*/
    @Transactional
    public void handle(Refunds refunds) {
        if (refunds != null && refunds.getStatus() == Refunds.Status.wait) {
            refunds.setStatus(Refunds.Status.success); //收款单状态变更
            update(refunds);
        }
    }

}
